<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/base.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>loading页面管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link type="text/css" href="<%=path%>/manage/css/layout.css" rel="stylesheet" />
	<link type="text/css" href="<%=path%>/manage/css/new_style.css" rel="stylesheet" />
	<script type="text/javascript" src="<%=path%>/manage/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="<%=path%>/manage/js/jquery-ui-1.8.11.custom.min.js"></script>
	<link href="<%=path%>/manage/css/uploadify.css" rel="stylesheet" type="text/css" />
	<script language="javascript"  src="<%=path%>/manage/js/swfobject.js"></script>
	<script language="javascript"  src="<%=path%>/manage/js/jquery.uploadify.v2.1.0.min.js"></script>
	<script language="javascript"  src="<%=path%>/manage/js/jquery.cookie.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			var type = "<s:property value='loadingType' />";
			if(type == 0){
				$("#picRadio").attr("checked",true);
			} else if (type == 1) {
				$("#videoRadio").attr("checked",true);
			}
		});
		function show(imgIdCount,type) {
			type =  $("input:radio[name='loading']:checked").attr("formatType");
			$("#uploadArea").load(root+"/manage/page/uploadFile.jsp",{'imgIdCount':imgIdCount,'type':type,'callback':'loadingUpCallBack'},function() {
				$("#uploadArea" ).dialog({
		            modal: true,
		            width:450,
		            resizable: false,
		            title:"请上传附件",
		            hide:"fade",
		            close:function( event, ui ) {
		            	$(this).dialog("destroy");
		            	$(this).empty();
		            }
		       });
		       $("#uploadArea" ).focus();
			});
	    }
	    function loadingUpCallBack(data,imgIdIndex) {
	    	var result = data.split(":");
    		$("#uploadSuccessInfo0").html(result[0]);
             $("#uploadSuccessUrl0").val(result[1]);
             var type = $("input:radio[name='loading']:checked").attr("formatType");
             if(type == 5){
               var content = '<img src="'+serverUrl+result[1]+'" width="200" height="180" id="imgArea" />';
             	$("#loadingContent").html(content);
             }
             if(type == 4) {
             	var content = '<video src="'+serverUrl+result[1]+'" controls="controls" preload="preload" width="200" height="180">您的浏览器不支持 video 标签。</video>';
             	$("#loadingContent").html(content);
             }
             $("#uploadArea").dialog("close");
	    }
	    function changeLoading() {
	    	var url = $("#uploadSuccessUrl0").val();
	    	if(url==""){
	    		alert("请先上传文件！");
	    	}
	    	$.ajax({
	    		url : root+'/more/changeLoading.action',
				method : 'post',
				dataType : 'json',
				data:{'url':url,'loadingIconId':$("#loadingIconId").val()},
				success : function(data) {
					alert("修改成功");
				},
				error:function(err){
					if(err.responseText!='')
						alert(err.responseText);
					else
						alert("请求失败！");
				}
	    	});
	    }
	</script>
  </head>

	<body>
		<div>
			<p class="sitemap">
				当前位置：客户端功能管理 > LOADING页面管理
			</p>
			<div style="margin:10px;">
				<input type="hidden" name="loadingIconId" id="loadingIconId" value="<s:property value='loadingIconId'/>" />
				<input type="radio" id="picRadio" name="loading" formatType="5">
				图片<br>
				<input type="radio" id="videoRadio" name="loading" formatType="4">
				视频
				<div style="margin:10px;">
					<input type='button' onclick='show(0,4)' value='上传' />
					<span id="uploadSuccessInfo0"></span>
					<input type="hidden" id="uploadFileName0" />
					<input type="hidden" id="uploadSuccessUrl0" value="<s:property value='loadingUrl' />"/>
				</div>
				<div id="loadingContent">
					<s:if test="loadingType==0">
						<img src="<s:property value='loadingUrl' />" width="200" height="180" id="imgArea" />
					</s:if>
					<s:if test="loadingType==1">
						<video src="<s:property value='loadingUrl'/>" controls="controls" preload="preload" width="200" height="180">
							您的浏览器不支持 video 标签。
						</video>
					</s:if>
				</div>
			</div>
			<input type="button" value="提交" onclick="changeLoading()" style="margin-left:200px;margin-top:20px;">
		</div>
		<div id="uploadArea"></div>
	</body>
</html>
